# Support setting various labels on the final image
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.16-alpine as builder

RUN apk add --no-cache gcc musl-dev linux-headers git

ADD . /go-blockchain
RUN cd /go-blockchain && go run build/ci.go install ./cmd/kinglory

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest

RUN apk add --no-cache ca-certificates
COPY --from=builder /go-blockchain/build/bin/kinglory /root/run/
COPY --from=builder /go-blockchain/x/deploy-testnet/miner-node/ /root/run/
RUN cd /root/run/ && ./kinglory --datadir ./node init kinglory.json

RUN chmod a+x /root/run/*
WORKDIR /root/run/

EXPOSE 8545 8546 30303 30303/udp
#ENTRYPOINT ["kinglory"]
ENTRYPOINT ["/root/run/entrypoint.sh"]

# Add some metadata labels to help programatic image consumption
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
